<template>
	<view class="info" :style="{paddingTop: paddingHeight + 'px'}">
		<nav-bar title="关于"></nav-bar>
		<view class="info_card">
			<image :src="img_2" class="device_mould" />
			<view class="name">
				由瑞代谢仪
			</view>
			<view class="content">
				<view class="d-c">
					<text class="l-q">蓝牙名称</text>
					<text class="answer">{{ deviceInfo.bluetoothName  ? deviceInfo.bluetoothName : 'xxxxxxxx' }}</text>
				</view>
				<view class="d-c">
					<text class="l-q">mac地址</text>
					<text class="answer">{{ deviceInfo.deviceMac ? deviceInfo.deviceMac : 'xx:xx:xx:xx:xx:xx' }}</text>
				</view>
				<view class="d-c">
					<text class="l-q">固件版本</text>
					<text class="answer">v{{ deviceInfo.firmwareVersion ?  deviceInfo.firmwareVersion : '---' }}</text>
				</view>
				<view class="d-c">
					<text class="l-q">算法版本</text>
					<text
						class="answer">v{{ deviceInfo.arithmeticVersion ? deviceInfo.arithmeticVersion : '---'}}</text>
				</view>
				<view class="d-c" style="margin-bottom: 0;">
					<text class="l-q">仪器数据更新时间</text>
					<text class="answer">{{ deviceInfo.updateTime ? deviceInfo.updateTime : '---' }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		findDeviceMsgByOne
	} from '@/api/index.js'
	export default {
		data() {
			return {
				paddingHeight: uni.getStorageSync('navbarHeight'),
				deviceInfo: undefined,
				img_2: 'http://oss.antaimedical.com/images/static/2024/08/66b47bc1e4b000d2c606b524bblrMJK2gq935a3581f5f3a72a294dcfd449f2b1e19c.png'
			}
		},
		onLoad(OPTIONS) {
			this.fetchData(OPTIONS.id)
		},
		methods: {
			async fetchData(id) {
				uni.showLoading({
					title: '加载中...'
				})
				let params = {
					id
				}
				try {
					const res = await findDeviceMsgByOne(params)
					uni.hideLoading()
					if (res.code == 200) {
						this.deviceInfo = res.data
					}
				} catch (e) {
					//TODO handle the exception
					uni.hideLoading()
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #FAFAFA !important;
		min-height: 100%;
	}
</style>
<style lang="scss" scoped>
	.info {
		padding: 48rpx;

		.info_card {
			width: 100%;
			padding: 118rpx 20rpx 20rpx;
			border-radius: 16rpx;
			background-color: #fff;
			margin: 48rpx 0 0;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;


			.device_mould {
				width: 120rpx;
				height: 320rpx;
			}

			.name {
				margin: 128rpx 0 48rpx;
				font-weight: 500;
				font-size: 36rpx;
				color: #333333;
			}

			.content {
				width: 100%;
				padding: 32rpx 48rpx;
				background: #FAFAFA;
				border-radius: 16rpx;

				.d-c {
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-bottom: 34rpx;

					.l-q {
						font-size: 24rpx;
						color: #666666;
					}

					.answer {
						font-weight: 500;
						font-size: 24rpx;
						color: #333333;
					}
				}
			}
		}
	}
</style>